<h1><?php echo $title; ?></h1>
<div class="noprint">
<?php if (isset($notice) || $notice = $this->session->flashdata('notification')):?>
<p class="notice"><?php echo $notice;?></p>
<?php endif;?>

<?php if (count($rows) == 0) : ?>
<p class="notice"><?php echo __("Nessuno risultato", $module);?></p>
<?php endif; ?>


<form method='post' action='<?php echo site_url('adozioni/contabilita/categorie') ?>'>

<fieldset style=" margin: auto;">
<legend>Scelta</legend>



<label for="anno"><?php echo __("Anno", $module) ?></label>
<select name="anno">
<?php foreach($anni as $a): ?>
<option value="<?php echo $a['anno'] ?>" <?php if($a['anno'] == $anno) echo " selected "; ?>><?php echo $a['anno']; ?></option>
<?php endforeach; ?>
</select>


<label for="excel">Excel <input type="checkbox" name="excel" value="1" /></label> 
<input type="submit" name="go" value="  Visualizza  "/>

</fieldset>

</form>
</div>
<?php if($rows): ?>
	<table class='list'>
	<?php 
	$nome_categoria = '';
	$lordo = 0;
	$trattenute = 0;
	$netto = 0;
	$i = 0;
	?>
<?php foreach($rows as $r): ?>
	
	<?php if($r['nome_categoria'] != $nome_categoria): ?>
		<?php if($lordo > 0): ?>
		<tr class='total'>
			<td style="text-align: right" class="total"><?php echo __("Totale", $module) ?></td>
			
			<td style="text-align: right" class="total"><?php echo format_euro($lordo) ?></td>
			<td style="text-align: right" class="total"><?php echo format_euro($trattenute) ?></td>
			<td style="text-align: right" class="total"><?php echo format_euro($netto) ?></td>
		</tr>
		<?php endif; ?>
	<?php
		$lordo = 0;
		$trattenute = 0;
		$netto = 0;
	?>
	<tr><td colspan=4 style="height: 30px"></td></tr>
	<tr>
		<th style="text-align: left;background-color: lightgreen; border-bottom: 2px solid lightgreen; font-size: 15px; font-weight: bold;" colspan=4><?php echo $r['nome_categoria'] ?></th>
	</tr>
	<tr>
		<th><?php echo __("Sottocategoria", $module) ?></th>
		<th><?php echo __("Lordo", $module) ?></th>
		<th><?php echo __("Trattenute", $module) ?></th>
		<th><?php echo __("Netto", $module) ?></th>
	</tr>
	<?php $nome_categoria = $r['nome_categoria']; ?>
	<?php endif; ?>

	<?php
		$lordo += $r['tot_lordo'];
		$trattenute += $r['tot_trattenuta'];
		$netto += $r['tot_netto'];
	?>
	<tr>
		<td><?php echo $r['nome'] ?></td>
		<td style="text-align: right"><?php echo format_euro($r['tot_lordo']) ?></td>
		<td style="text-align: right"><?php echo format_euro($r['tot_trattenuta']) ?></td>
		<td style="text-align: right"><?php echo format_euro($r['tot_netto']) ?></td>
		
	</tr>
<?php endforeach; ?>
	<tr class='total'>
		<td style="text-align: right" class="total"><?php echo __("Totale", $module) ?></td>
		
		<td style="text-align: right" class="total"><?php echo format_euro($lordo) ?></td>
		<td style="text-align: right" class="total"><?php echo format_euro($trattenute) ?></td>
		<td style="text-align: right" class="total"><?php echo format_euro($netto) ?></td>
	</tr>
<?php endif; ?>
</table>
